//
//  ZCTableViewCell.m
//  BaiSi
//
//  Created by 张灿 on 16/4/27.
//  Copyright © 2016年 张灿. All rights reserved.
//

#import "ZCTableViewCell.h"
#import <UIImageView+WebCache.h>
#import "ZCTagItem.h"

@interface ZCTableViewCell ()
@property (weak, nonatomic) IBOutlet UIImageView *imageV;

@property (weak, nonatomic) IBOutlet UILabel *title;

@property (weak, nonatomic) IBOutlet UILabel *detailTitle;
@end

@implementation ZCTableViewCell

//重写set方法,当外界传模型进来时就会给cell赋值
- (void)setItem:(ZCTagItem *)item
{
    _item = item;
    [self.imageV sd_setImageWithURL:[NSURL URLWithString:item.image_list] placeholderImage:[UIImage imageNamed:@"defaultUserIcon"]];
    self.title.text = item.theme_name;
    
    NSInteger num = [item.sub_number integerValue];
    NSString *nstr = [NSString stringWithFormat:@"%@人已订阅", item.sub_number];
    if (num > 10000) {
        CGFloat numF = num / 10000.0;
        nstr = [NSString stringWithFormat:@"%.1f人已订阅", numF];
        //去除.0
        nstr = [nstr stringByReplacingOccurrencesOfString:@".0" withString:@""];
    }
    
    self.detailTitle.text = nstr;
}

//只会调用一次
//当对象从xib加载完成时调用
- (void)awakeFromNib {
    [super awakeFromNib];
    self.imageV.layer.cornerRadius = self.imageV.width * 0.5;
    //超过圆角的就裁剪
    self.imageV.layer.masksToBounds = YES;
}

//重写cell的设置frame方法,使其高度减1,造成空隙,即分割线
- (void)setFrame:(CGRect)frame
{
    frame.size.height -= 1;
    [super setFrame:frame];
}


@end
